import numpy as np
import cv2
import pickle

from sklearn.mixture import GaussianMixture

# ------ 设置打印是完整打印 --------
np.set_printoptions(threshold=np.inf)

initImg = cv2.imread('./data/primitive_data.jpg')
# initImg = cv2.imread('./data/ningxiang/2.jpg')
# cv2.imshow('initImg', initImg)

train_data = initImg.reshape(initImg.shape[0] * initImg.shape[1], 3)

gm = GaussianMixture(n_components=2, random_state=0).fit(train_data)

print(gm.means_)

s = pickle.dumps(gm)
f = open('model/model_0.bin','wb')
f.write(s)

cv2.waitKey(0)
cv2.destroyAllWindows()
